 <meta charset="utf-8">
 <div class="box" id="biz_authRole_conatainer">
            <div class="box-header with-border">
               <form id="searchForm" role="form" class="form-inline">
                    <div class="form-group">
                         <label>角色名称</label>
                         <input name="name" v-model="searchForm.name"   type="text" placeholder="" class="form-control">
                    </div>
                    <div class="form-group">
                    <label>角色代码</label>
                         <input name="roleCode" v-model="searchForm.roleCode"  id="roleCode" type="text" placeholder="" class="form-control">
                    </div>
                     <div class="form-group" >
					 <label>所属应用</label>
						 <select id="appKey" v-model="searchForm.appKey"  name="appKey" v-kselect="{url:'auth/authApp/loadAuthAppComboboVo',vmodel:'searchForm.appKey',firstEmpty:'false'}" class=" form-control"> </select>
					</div>
                     <div class="form-group">
                    <label>是否启用</label>
                          <select class="form-control"  v-model="searchForm.enabled"  name="enabled" >
                        		  <option value="">请选择</option>
                                  <option value="true">启用</option>
                                  <option value="false">禁用</option>
                           </select>
                    </div>
                     <button type="button"  class="btn btn-info pull-right m-t-n-xs" v-kperms="{perm:'authRole:loadAuthRoleList'}"  v-on:click="search();"><strong>查询</strong></button>
                </form>
            </div>
 <div class="box-body">
 	<div class="row">
 	  <div class="col-md-12">
 	                           <div class="btn-group " id="authRoleBootstrapTableToolbar" role="group">
 	                           		<button type="button" v-kperms="{perm:'authRole:addRole'}"  class="btn btn-default" v-on:click="add">
                                        <i class="glyphicon glyphicon-plus" aria-hidden="true"></i> 添加
                                    </button>
                                     <button type="button"  v-kperms="{perm:'authRole:updateRole'}" class="btn btn-default" v-on:click="edit">
                                        <i class="glyphicon glyphicon-pencil" aria-hidden="true"></i> 修改
                                    </button>
                                     <button type="button"  v-kperms="{perm:'authRole:updatePermission'}" class="btn btn-default" v-on:click="assignPrem">
                                        <i class="glyphicon glyphicon-pencil" aria-hidden="true"></i> 权限分配
                                    </button>
                                    <button type="button"  v-kperms="{perm:'authRole:deletAuthRole'}" class="btn btn-default" v-on:click="deletex">
                                        <i class="glyphicon glyphicon-trash" aria-hidden="true"></i> 删除
                                    </button>
                                     <button type="button"  v-kperms="{perm:'authRole:setAuthRoleEnabled'}" class="btn btn-default" v-on:click="setEnable">
                                        <i class="glyphicon glyphicon-ok" aria-hidden="true"></i> 启用
                                    </button>
                                     <button type="button"  v-kperms="{perm:'authRole:setAuthRoleEnabled'}" class="btn btn-default" v-on:click="setDisable">
                                        <i class="glyphicon glyphicon-remove" aria-hidden="true"></i> 禁用
                                    </button>
                           </div>
                                
           <table id="ahthRoleBootstrapTable" data-mobile-responsive="true" ></table>
 	  </div>
 	</div>
 </div>
 </div>

<script> 
new Vue({  
	  el: '#biz_authRole_conatainer',  
	  data:{
		  searchForm:{
			  name: null,
			  roleCode: null,
			  appKey: null,
			  enabled: null
		  },
		  bus:new Vue(),
	  },
	  mounted:function(){
		 let _this=this;
		 _this.bus.$on(zfesVueDirective.getKselectOnInitEventName("appKey"), function (msg) {
				_this.initTable();
		 });
	  },
  methods: {
	  initTable:function(){
		  let columns=[
				{checkbox:true},
				{field:'roleCode',title:'角色编码',width:160,sortable:true},
				{field:'name',title:'角色名称',width:160},
				{field:'enabled',title:'是否启用',width:100,formatter:zfesUtil.formatEnabled},
				{field:'appName',title:'所属应用',width:100},
				{field:'description',title:'角色描述',width:300}];
		  let url="auth/authRole/loadAuthRoleList";
  		zfesBstable.laodTable($("#ahthRoleBootstrapTable"),$("#searchForm"),$("#authRoleBootstrapTableToolbar"),url,columns,this.searchForm);
	  },
	  search:function(){
		  zfesBstable.reload($("#ahthRoleBootstrapTable")); 
	  },
	  refresh:function(){
		  zfesBstable.refresh($("#ahthRoleBootstrapTable"));
	  },
	  add:function(){
		  let　_this=this;
		 var url="/view/auth/authRole/authRole.add.html";
		 zfesLayerEditDg.open(url,{},"角色信息编辑",460,function(){_this.refresh();});
		 
	  },
	  edit:function(){
		  if(zfesBstable.isOneRow($("#ahthRoleBootstrapTable"))){
			  let　_this=this;
			  let id=zfesBstable.getRowId($("#ahthRoleBootstrapTable"));
			  var url="/view/auth/authRole/authRole.edit.html";
			  zfesLayerEditDg.open(url,{"id":id},"角色信息编辑",460,function(){_this.refresh();}); 
		 }
	  },
	  setEnable:function(){
		  if(zfesBstable.isSelectedRow($("#ahthRoleBootstrapTable"))){
			  let ids=zfesBstable.getRowIds($("#ahthRoleBootstrapTable"));
			  let　_this=this;
				 alertSwal.confirm("启用","是否执行该操作",function(){
						    let ajaxUrl = "auth/authRole/setAuthRoleEnabled";
						    zfesAjax.ajaxTodo(ajaxUrl, { "ids" : ids,"enabled":true}, function(data) {
								alertSwal.successText(data.message);
								_this.refresh();
							});
						});
		  }
	  },
	  setDisable:function(){
		  if(zfesBstable.isSelectedRow($("#ahthRoleBootstrapTable"))){
			  let ids=zfesBstable.getRowIds($("#ahthRoleBootstrapTable"));
			  let　_this=this;
				 alertSwal.confirm("禁用","是否执行该操作",function(){
						    let ajaxUrl = "auth/authRole/setAuthRoleEnabled";
						    zfesAjax.ajaxTodo(ajaxUrl, {"ids" : ids,"enabled":false}, function(data) {
								alertSwal.successText(data.message);
								_this.refresh();
						});
		  		});
		  }
	  },
	  deletex:function(){
			if(zfesBstable.isOneRow($("#ahthRoleBootstrapTable"))){
				  let　_this=this;
					var id=zfesBstable.getRowId($("#ahthRoleBootstrapTable"));
					 alertSwal.confirm("删除","是否执行该操作",function(){
						    let ajaxUrl = "auth/authApp/removePermsFromRole";
							zfesAjax.ajaxTodo(ajaxUrl, { "id" : id}, function(data) {
								alertSwal.successText(data.message);
								_this.refresh();
							},function(data){
								
							}); 
				});
			}
				
	  },
	  assignPrem: function(){
		  let _this=this;
		  if(zfesBstable.isOneRow($("#ahthRoleBootstrapTable"))){
				 let id=zfesBstable.getRowId($("#ahthRoleBootstrapTable"));
				 let url="/view/auth/authRole/authRole.prem.assign.html";
				 zfesLayerEditDg.open(url,{"roleId":id},"权限分配",1000,function(){zfesBstable.refresh($("#ahthRoleBootstrapTable"));}); 
			 }
	  }
 	
 }

});
</script>


